Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GameObject change undo/redo refactor to track different options #3085

Merged
merged 8 commits into from
Oct 24, 2024

Conversation

Vankata453
Copy link
Member

GameObject, instead of comparing all options against each other, now saves the state of and compares individual ones, so the change data is more memory-efficient.

This way of tracking object changes also allows for proper undo/redo tracking with multiple remote users (regarding the remote level editing concept, which branch these changes originate from).

TileMap tile changes are now saved in a way more memory-efficient way. Instead of saving the whole tiles array for each change, only the changed tiles are saved in a list of pairs (tile index, old/new tile ID).

When reading an array, it is only cleared right before new items are going to be added, instead of it being done before an attempt to read the value has been made.
`GameObject`, instead of comparing all options against each other, now saves the state of and compares individual ones, so the change data is more memory-efficient.

This way of tracking object changes also allows for proper undo/redo tracking with multiple remote users.

`GameObjectState` was renamed to `GameObjectChange`, since it does not always preserve all object options anymore.

TODO: Proper tilemap tile-change tracking
Previously, an assertion was used for performing this check, which was the cause of the crash. It wasn't taken into account performing undo/redo on a remotely-deleted object.

Additionally, the warning message now includes the class name of the object.
`TileMap` tile changes are now stored in pairs, containing a tile array index and old/new tile, which takes its place.

Allows for lighter storage in memory for undo/redo, as well as for lower-sized packets and proper remote tile undo/redo with editor remote level networking.
@tobbi
Copy link
Member

tobbi commented Oct 21, 2024

MacOS build failure:

In file included from /Users/runner/work/supertux/supertux/src/supertux/game_object_change.cpp:17:
/Users/runner/work/supertux/supertux/src/supertux/game_object_change.hpp:65:33: error: implicit instantiation of undefined template 'std::vector<GameObjectChange>'
  std::vector<GameObjectChange> objects;
                                ^
/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/c++/v1/iosfwd:259:28: note: template is declared here
class _LIBCPP_TEMPLATE_VIS vector;

Windows build failure (maybe if the logs don't deceive me):
https://github.com/SuperTux/supertux/actions/runs/11448138595/job/31851014184?pr=3085#step:6:4092

@Vankata453 Vankata453 merged commit bda676b into master Oct 24, 2024
@Vankata453 Vankata453 deleted the undo-redo-refactor branch October 24, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants